@extends('admin.main')
<?php
$web = '/admin/';
$clasname = $context->getName();
?>
@section('content')
    <div id="content" class="content admin-content">
        <div class="am-g">
            <!-- begin breadcrumb -->
            <ol class="breadcrumb pull-right">
                <?= $context->breadcrumb ?>
            </ol>
            <!-- end breadcrumb -->
            <!-- begin page-header -->
            <p class="page-header"><?= $context->topTitle ?>
                <small></small>
            </p>
            <!-- end page-header -->
            <!-- begin row -->

            <div class="am-u-sm-12 am-u-md-4 am-u-md-push-8"></div>
            <div class="FormContentDiv am-u-sm-12 am-u-md-8 am-u-md-pull-4">
                <form action="<?= $context->action ?>" class="am-form"
                      method="POST"
                      enctype="multipart/form-data">
                    <input type="hidden" name="_token" value="{{csrf_token()}}">
                    <?php
                    $primaryKey = $context->get_primaryKey();
                    $keyvalue = '';
                    $modelone = $context->getOneModel();
                    if ($modelone) {
                        $keyvalue = $modelone[$primaryKey];
                    }
                    ?>
                    <input type="hidden" name="<?= $primaryKey ?>" value="<?= $keyvalue ?>">
                    <input type="hidden" name="ispost" value="<?= $ispost ?>">
                    <input type="hidden" name="save" value="<?= $save ?>">
                    <?php

                    foreach ($context->Labels() as $vo) {
                        echo "<div class='formli'>";
                        echo $context->renderTag($vo);
                        echo "</div>";
                    }

                    if ($context->submit && $context->submit !== '') {
                        echo '<button class="am-btn am-btn-primary" type="submit">' . $context->submit . '</button>';
                    }

                    ?>

                </form>


            </div>
        </div>
    </div>
    <link href="<?= $web ?>lcms/baseview.css" rel="stylesheet">
    <script src="<?= $web ?>lcms/home2.0.js"></script>
    <script src="<?= $web ?>lcms/artdialog/artDialog.js?skin=aero"></script>

    <link href="<?= $web ?>lcms/editor/themes/default/default.css" rel="stylesheet">
    <script charset="utf-8" src="<?= $web ?>lcms/editor/kindeditor-min.js"></script>
    <script charset="utf-8" src="<?= $web ?>lcms/editor/lang/zh_CN.js"></script>
    <script>
        var imgbtn = $('.FormContentDiv [fileimg]');
        for (var i = 0; i < imgbtn.length; i++) {
            var one = $(imgbtn[i]);
            MC.API.bindFileUp(one, function (data, obj) {
                var name = obj.attr('fileimg');
                console.log(data);
                $('[name=' + name + ']').val(data);
                $('[field=' + name + ']').attr('src', data);
            });
        }
        var textareaList = $('.kindeditor');
        for (var i = 0; i < textareaList.length; i++) {
            var one = textareaList[i];
            one.K = KindEditor.create(one);
        }
        var ispost = $('[name=ispost]').val();
        var save = $('[name=save]').val();
        if (ispost && save) {
            MC.msg.show("保存成功");
        }
        $('.am-form').on('submit', function () {
            for (var i = 0; i < textareaList.length; i++) {
                var one = textareaList[i];
                one.K.sync();
            }
            return true;
        });

    </script>
@stop